package com.ruoyi.kafka.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/kafka")
public class KafkaController {

    @Resource
    private KafkaTemplate kafkaTemplate;
    @PostMapping("/straight")
    public void sendMessage(){

        //  topic 根据具体的需求决定把代码待到那个消费者处   点对点展示

        String topic = "topictest1";

        String testJson="123";

        kafkaTemplate.send(topic,testJson);
    }
}
